﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _03ConvertDecToHex
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Ënter a number to convert to Hex:");
            int nDec = int.Parse(Console.ReadLine());
            int easyDec = nDec;
            int remainder;
            List<string> hexList = new List<string>();
            while (nDec > 0)
            {
                remainder = nDec % 16;
                nDec = nDec / 16;
                if (remainder > 9)
                {
                        switch (remainder)
                    {
                        case 10: hexList.Add("A"); break;
                        case 11: hexList.Add("B"); break;
                        case 12: hexList.Add("C"); break;
                        case 13: hexList.Add("D"); break;
                        case 14: hexList.Add("E"); break;
                        case 15: hexList.Add("F"); break;
                        case 0: hexList.Add("0"); break;
                        default:
                            break;
                    }
                }
                if (remainder <= 9)
                {
                    hexList.Add("" + remainder);
                }
            }
            hexList.Reverse();
            Console.Write("In Hex this number is:");
            foreach (var item in hexList)
            {
                Console.Write(item);
            }
            Console.WriteLine();
            Console.WriteLine("In another way it still is:{0:X}", easyDec);
            Console.WriteLine();
        }
    }
}
